using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace 综合同步
{
    public class Program
    {
        [DllImport("user32.dll")]
        public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
        public static void Main(string[] args)
        {
            try{
                LocalServer.instance();
                CreateHostBuilder(args).Build().Run();
            }catch(Exception e){
                FileLogOperator.Error(e.Message);
                Task.Run(()=>{
                    Thread.Sleep(6000);
                    keybd_event(0x1b, 0, 0, 0);
                });
                Console.ReadKey();
            }
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    // webBuilder.ConfigureKestrel((context, options) =>{
                    //     options.Limits.MaxRequestBodySize = 400*1024*1024;
                    // });
                    webBuilder.UseStartup<Startup>();
                });
    }
}
